package com.tinyseed.hmxx.admin.system.repository;

import com.tinyseed.hmxx.admin.system.domain.Role;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.Set;

/**
 * @version Revision 1.0.0
 * @版权：
 * @author: Howard
 * @email:
 * @see:
 * @创建日期：2020/3/4
 * @功能说明：权限service
 * @begin
 * @修改记录:
 * @修改后版本 修改人        修改内容
 * @2020/3/4 wuxiran        创建
 * @end
 */
public interface RoleRepository extends JpaRepository<Role, Long>, JpaSpecificationExecutor<Role> {

    Role findByName(String name);

    Set<Role> findByUsers_Id(Long id);

    @Modifying
    @Query(value = "delete from roles_menus where menu_id = ?1", nativeQuery = true)
    void untiedMenu(Long id);
}

